<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="num1">
    <input type="text" id="num2">
    <button id="btn">计算和</button>
    <input type="text" id="res">
    <script>
        var num1Ele = document.getElementById("num1");
        var num2Ele = document.getElementById("num2");
        var btn = document.getElementById("btn");
        var res = document.getElementById("res");
        function fn(a,b) {
            var c = parseInt(a);
            var d = parseInt(b);
            console.log( c + d );
        }
        btn.onclick = fn(num1Ele.value,num2Ele.value);
    </script>
</body>
</html>